<?php
namespace Admin\Controller;
use Admin\Controller\AdminController;
class LiuyanController extends AdminController {
 	//xuxiang
	public function _initialize(){
 		parent::_initialize();
	}
	/**
	 * 留言列表
	 */
	public function liuyanList(){
		//是否登录
		//列出收藏列表
		$count = M("Liuyan")->count();
		$Page  = new \Think\Page($count,20);
		// 		setPageParameter($Page, $post);
		$show = $Page->show();
		$list = M('Liuyan')->order("add_time desc")->limit($Page->firstRow.','.$Page->listRows)->select();
		foreach($list as $k=>$v){
			$nickname = M('Member')->field('nickname')->where(array('openid'=>$v['open_id']))->find()['nickname'];
			$list[$k]['nickname'] = $nickname;
			$list[$k]['goods'] = M('Order_goods')->where(array('id'=>$v['order_goods_id']))->find();
			$list[$k]['attr'] = M('Attr')->where(array('attr_id'=>$list[$k]['goods']['arrt_id']))->find();
		}
		$this->assign('list',$list);
		$this->display();
	}
	
	/**
	 * 添加留言回复
	 */
	public function setLiuyan(){
		$liuyan_id = I('liuyan_id');
		$data['hf_content'] = I('hf_content');
		$data['hf_time'] = time();
		$re = M('Liuyan')->where(array('liuyan_id'=>$liuyan_id))->save($data);
		if($re){
			$this->success('操作成功',U('Liuyan/LiuyanList'));
		}else{
			$this->error('操作失败');
		}
	}
	
	/**
	 * 删除留言
	 */
	public function delLiuyan(){
	
	}
}